package com.link2room.jetfire.nmsrunner;

import com.aliyun.mns.model.Message;
import com.link2room.jetfire.dto.param.inside.ReservationNmsStaInsideParamDto;
import com.link2room.common.mns.Worker;
import com.link2room.common.util.JacksonUtil;
import com.link2room.jetfire.facade.IReservationFacadeService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by sss on 2016/9/21.
 */
@Component("reservationNmsStaRunner")
public class ReservationNmsStaImpl implements Worker {
    @Resource
    private IReservationFacadeService reservationFacadeService;

    @Override
    public boolean exec(Message message) throws Exception {
        try{
            ReservationNmsStaInsideParamDto reservationNmsStaInsideParamDto = JacksonUtil.jsonToBean(message.getMessageBody(), ReservationNmsStaInsideParamDto.class);
            if(message.getDequeueCount()==1){
                reservationFacadeService.updateReservationNmsSta(reservationNmsStaInsideParamDto);
            }
        }catch (Exception e){
            throw new RuntimeException();
        }finally {
            return true;
        }
    }
}
